package com.dream.spring.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import com.dream.spring.bean.User;
import com.dream.spring.service.UserService;

/**
* @author FanZhiCheng
* @version 创建时间：2019年9月23日 下午2:38:49
* 类说明
*/
public class UserController implements Controller {

	private UserService service;
	
	public void setService(UserService service){
		this.service= service;
	}
	
	
	@Override
	public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
		
		String username= request.getParameter("username");
		String password= request.getParameter("password");
		String mailaddress= request.getParameter("mailaddress");
		String phonenumber= request.getParameter("phonenumber");
		
		User user=new User(username,password,mailaddress,phonenumber);
		service.addUser(user);
		return new ModelAndView("/welcome.jsp");
	}

}
